package com.link2room.rodimus.service.impl;

import com.link2room.common.dao.ICommonDao;
import com.link2room.common.service.ICommonService;
import com.link2room.rodimus.entity.SalesmanBase;
import com.link2room.rodimus.entity.SalesmanIncomeDetail;
import com.link2room.rodimus.entity.SalesmanIncomingdetailLogEntity;
import com.link2room.rodimus.entity.SalesmanPayment;
import com.link2room.rodimus.service.ISalesmanRewardsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by VegetaKo on 2016/11/14.
 */
@Service("salesmanRewardsService")
public class SalesmanRewardsServiceImpl implements ISalesmanRewardsService {
    @Resource
    private ICommonService commonService;

    @Resource
    private ICommonDao commonDao;
    @Override
    @Transactional
    public void updateSalesmanRewardsPayments(SalesmanBase salesmanBase, List<SalesmanIncomeDetail> salesmanIncomeDetails, SalesmanPayment salesmanPayment) throws Exception {

        commonService.merge(salesmanBase );
        commonService.mergeList(salesmanIncomeDetails );
        commonService.merge(salesmanPayment );
    }

    @Override
    @Transactional
    public void salesmanIncomingdetailLog(SalesmanIncomeDetail salesmanIncomeDetail, SalesmanIncomingdetailLogEntity log) throws Exception {
        commonDao.merge(salesmanIncomeDetail);
        commonDao.save(log);
    }
}
